<?php
namespace Admin\Controller;
use Think\Controller;
class FiledController extends Controller{
	public function index(){
		$mid=I('mid');
		$data=S('f');
		// p($data);exit;
		
		if(empty($data)){//最好是再判断一下数组里名有没有等于$mid的数据
			$db=M('filed')->where("mid=$mid")->select();
		}else{
			$db=array();
			foreach ($data as $k => $v){
				if($mid==$v['mid']){
					$db[]=$v;
				}
			}
		}
			
		$this->assign('data',$db);
		$this->assign('mid',$mid);
		$this->display();

	}

	//添加字段
	public function add(){
		
		$Model=D('Filed');
		if($Model->d()){
			$this->success('添加成功');
		}else{
			$this->error('添加失败');
		}
	
	}

	//缓存
	public function updateCache(){
		$Model=D('Filed');
		if($Model->updateCache()){
			echo 1;
		}else{
			echo 0;
		}
	}












}